package com.own.component.util.database.model;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * TableSchema
 *
 * @author chenxueli
 * @date 2022-10-15 14:09:20
 */
@ToString
public class TableSchema implements Serializable {

    @Getter
    private final Set<String> importArray = new HashSet<>();

    @Setter
    @Getter
    private String tableName;

    @Setter
    @Getter
    private String comment;

    @Getter
    private List<TableColumnModel> list = new ArrayList<>();

    public void setList(List<TableColumnModel> list) {
        this.list = list;
        // 设置导入包
        list.stream()
                .map(TableColumnModel::getPath)
                .filter(StringUtils::isNotEmpty)
                .forEach(importArray::add);
    }

}
